//
// Created by vcq on 21/4/2.
//
#include "model/goal.hpp"
static void GetGoal(request& req, response& res) {
    if(!check_login(req,res)){
        return;
    }
    basic_string_view<char> id = req.get_query_value("id");
    basic_string_view<char> _plan_id = req.get_query_value("_plan_id");
    json item= MGetGoal(id, _plan_id);
    res.set_status_and_content(status_type::ok, item.dump(),req_content_type::json);
}
static void SaveGoal(request& req, response& res) {
    if(!check_login(req,res)){
        return;
    }
    struct goal goal1{};
    goal1.id = atoi(req.get_query_value("id").data());
    goal1.name=req.get_query_value("name");
    goal1.note=req.get_query_value("note");
    goal1._plan_id=atoi(req.get_query_value("_plan_id").data());
    MAddGoal(goal1);
    res.set_status_and_content(status_type::ok);
}
static void DeleteGoal(request& req, response& res) {
    if(!check_login(req,res)){
        return;
    }
    MDeleteGoal(req.get_query_value("id"));
    res.set_status_and_content(status_type::ok);
}

